var appId;
var timeStamp;
var nonceStr;
var signature;
var shareImgUrl;
var shareLink= window.location.href;
var thisUrl = window.location.href;
var host_ = window.location.host;
var realShareLink = '';
var sharedescContent = '';
var shareTitle = '';

var UvUrl= window.location.pathname;
$(function(){

  if(thisUrl.indexOf("http") < 0){
    thisUrl = "http://"+ window.location.href;
  }
  if(shareLink.indexOf("http") < 0){
    shareLink = "http://"+ window.location.href;
  }

  getRealLink();

})
function getRealLink() {
  $.ajax({
    async: false,
    url: '/share/signature',
    type: 'GET',
    dataType: 'json',
    data: {url: thisUrl,shareUrl:shareLink},
    success:function(data){
      if(data.success)
      {
        appId = data.result.app_id;
        timeStamp = data.result.timestamp;
        nonceStr = data.result.noncestr;
        signature = data.result.signature;
        realShareLink = data.result.share_url;
        // alert(realShareLink)
        wx.config({
          debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
          appId: appId, // 必填，公众号的唯一标识
          timestamp:timeStamp, // 必填，生成签名的时间戳
          nonceStr: nonceStr, // 必填，生成签名的随机串
          signature: signature,// 必填，签名，见附录1
          jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage','chooseImage','uploadImage','downloadImage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
        });
      }
    }
  })
}
